|
|
 |
|
|
|
|
' Erase the form. Cls
CurrentX = min_x
y = 0
' Make the list of font names. Set font_names = New Collection
font_names.Add "Times New Roman"
font_names.Add "Courier New"
font_names.Add "Arial"
font_names.Add "MS Sans Serif"
' Break the string into words. length = Len(txt)
pos1 = 1
Do ' Get the next word. pos2 = InStr(pos1, txt, " ")
If pos2 = 0 Then
new_word = Mid$(txt, pos1)
Else
new_word = Mid$(txt, pos1, pos2 - pos1)
End If
pos1 = pos2 + 1
' Randomly select a ForeColor. clr = QBColor(Int(16 * Rnd))
If clr = BackColor Then clr = vbBlack
ForeColor = clr
' Randomly pick Font properties.
' (The Underline and Strikethrough
' properties make things too cluttered.) Font.Name = font_names(Int(font_names.Count * _
Rnd + 1))
Font.Size = Int((max_size - min_size + 1) * _
Rnd + min_size)
Font.Bold = (Int(2 * Rnd) = 1)
Font.Italic = (Int(2 * Rnd) = 1)
' If the word won't fit, start a new line. If CurrentX + TextWidth(new_word) > max_x Then
CurrentX = min_x
y = y + 1.25 * max_size
End If
' Display the text. CurrentY = y + max_size - Font.Size
Print new_word; " ";
Loop While pos2 > 0
End Sub |
|
|
|
|
|